package com.rcklos.bottomnavgationdemo;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.rcklos.bottomnavgationdemo.activity.Nav1Activity;
import com.rcklos.bottomnavgationdemo.activity.Nav2Activity;
import com.rcklos.bottomnavgationdemo.activity.Nav3Activity;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        ((Button)findViewById(R.id.btn1)).setOnClickListener(this);
        ((Button)findViewById(R.id.btn2)).setOnClickListener(this);
        ((Button)findViewById(R.id.btn3)).setOnClickListener(this);
    }

    private void switchView(int v){
        Intent intent = null;
        switch (v){
            case 1:
                intent = new Intent(this, Nav1Activity.class);
                break;
            case 2:
                intent = new Intent(this, Nav2Activity.class);
                break;
            case 3:
                intent = new Intent(this, Nav3Activity.class);
                break;
        }
        if( intent!= null) startActivity(intent);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.btn1:
                switchView(1);
                break;
            case R.id.btn2:
                switchView(2);
                break;
            case R.id.btn3:
                switchView(3);
                break;
        }
    }
}